﻿<div>

<script type="text/javascript">
    $(function () {
        $("#t1").treegrid({
            title: 'test treegrid',
            width: 900,
            height: 400,
            method: "get",
            url: "treegrid/treegrid-data.json",
            idField: 'id',
            treeField: 'name',
            remoteSort: false,
            frozenColumns: [[
                { field: 'ck', checkbox: true, rowspan: 2 },
                { field: 'id', title: 'ID(id)', width: 80, sortable: true, rowspan: 2 }
            ]],
            columns: [[
                { field: 'name', title: '名称(name)', width: 180, sortable: true, rowspan: 2 },
                { field: 'age', title: '年龄(age)', width: 120, sortable: true, rowspan: 2 },
                { title: '附加信息', colspan: 3 },
                //{ field: 'weight', title: '体重(weight)', width: 120, sortable: true },
                //{ field: 'size', title: 'Size(size)', width: 140 },
                //{ field: 'date', title: '日期(date)', width: 140, sortable: true },
                { field: 'undefined', title: '测试(不存在的字段)', width: 140, rowspan: 2 }
            ], [
                { field: 'weight', title: '体重(weight)', width: 100, sortable: true },
                { field: 'size', title: 'Size(size)', width: 80 },
                { field: 'date', title: '日期(date)', width: 100, sortable: true }
            ]],
            headerContextMenu: [
                { text: "测试菜单1", iconCls: "icon-hamburg-address", disabled: false, handler: function () { alert(1); } },
                { text: "测试菜单2", iconCls: "icon-hamburg-busy", disabled: false, handler: function (e, field) { alert($.string.format("您点击了{0}", field)); } }
            ],
            enableHeaderClickMenu: true,
            enableHeaderContextMenu: true,
            enableRowContextMenu: false
        });
    });
</script>

<h2>jEasyUI TreeGrid Extensions - 表头自定义右键菜单</h2>
<p>该部分扩展由文件 jeasyui.extensions.treegrid.js 实现。</p>
<hr />
<p>用鼠标右键点击此表格表头列试试看</p>
<table id="t1"></table>

</div>